Clone ObjectMethod before toExpression in preset (#58424) - #58424
Closed
vzaidman wants to merge 2 commits into
Closed
Clone ObjectMethod before toExpression in preset (#58424)#58424vzaidman wants to merge 2 commits into
vzaidman wants to merge 2 commits into
Conversation
…oad the correct commit data. Differential Revision: D119065685
|
@vzaidman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D119305530. |
Summary: Pull Request resolved: #58424 The React Native Babel preset replaces `Platform.select({...})` with the selected property during production transforms. When the selected property is an object method, converting it to an expression mutates the node in place. Since the replacement is computed before the purity check, bailing out on an impure sibling leaves the mutated method behind, producing invalid output. Clone the method before converting it. Also assess purity on the property itself: an `ObjectMethod` has no value, so checking the value treated every method as impure and skipped inlining. ## Changelog: [GENERAL] [FIXED] - Fix Platform.select inlining producing invalid output for object methods when discarding impure initializers is skipped Reviewed By: GijsWeterings Differential Revision: D119305530
meta-codesync
Bot
force-pushed
the
export-D119305530
branch
from
September 9, 2026 15:10
a4bdfc4 to
eafde44
Compare
|
This pull request has been merged in 88748a7. |
|
This pull request has been reverted by c1ad8ae. |
shashikant-panchal
pushed a commit
to shashikant-panchal/react-native
that referenced
this pull request
Sep 10, 2026
Summary: Pull Request resolved: react#58424 The React Native Babel preset replaces `Platform.select({...})` with the selected property during production transforms. When the selected property is an object method, converting it to an expression mutates the node in place. Since the replacement is computed before the purity check, bailing out on an impure sibling leaves the mutated method behind, producing invalid output. Clone the method before converting it. Also assess purity on the property itself: an `ObjectMethod` has no value, so checking the value treated every method as impure and skipped inlining. ## Changelog: [GENERAL] [FIXED] - Fix Platform.select inlining producing invalid output for object methods when discarding impure initializers is skipped Reviewed By: GijsWeterings Differential Revision: D119305530 fbshipit-source-id: dd30a94e91ed8a024377acf4230698439eef8b1b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The React Native Babel preset replaces
Platform.select({...})with the selected property during production transforms. When the selected property is an object method, converting it to an expression mutates the node in place. Since the replacement is computed before the purity check, bailing out on an impure sibling leaves the mutated method behind, producing invalid output. Clone the method before converting it.Also assess purity on the property itself: an
ObjectMethodhas no value, so checking the value treated every method as impure and skipped inlining.Changelog:
[GENERAL] [FIXED] - Fix Platform.select inlining producing invalid output for object methods when discarding impure initializers is skipped
Reviewed By: GijsWeterings
Differential Revision: D119305530